import{U as l}from"./CwAUA1OU17ghgo.js";import{bp as f,b1 as w}from"./DrFvzlh8agutd.js";import{a9 as m,C as c,o as y,$,e as n,H as T}from"./MpnPZlTSagutd.js";var i={cache:"no-cache",redirect:"follow",headers:{}};function d(r){let t=/:\/\/([^@]*)@/.exec(r);if(t&&t[1]){let[a,e]=t[1].split(":",2);return{url:r.replace(`${t[1]}@`,""),username:a,password:e}}}n(d,"parseBasicAuth");async function h(r,t={},a=fetch){try{y(t)&&(t=f({},...w(t)));let e=d(String(r));e&&(r=e.url,t=f({},t,u(e.username,e.password))),t.headers!=null&&!(t.headers instanceof Headers)&&(t.headers=new Headers(t.headers));let o=await a(String(r),t);if(o.status<400)return o;let s=c("zeed:network");try{s.warn(`Fetch of ${String(r)} returned status=${o.status}. Options:`,t),s.warn(`Response: ${await o.text()}`)}catch(p){s.error("Exception:",p)}}catch(e){c("zeed:network").error("fetchBasic",e)}}n(h,"fetchBasic");async function x(r,t={},a=fetch){try{let e=await h(r,[{method:"GET",headers:{Accept:"application/json"}},t],a);if(e)return m(await e.text())}catch(e){c("zeed:network").error("fetchJSON error:",e)}}n(x,"fetchJson");async function O(r,t={},a=fetch){try{let e=await h(r,[i,{method:"GET"},t],a);if(e)return await e.text()}catch(e){c("zeed:network").error("fetchHTML error:",e)}}n(O,"fetchText");function b(r,t="POST"){return{method:t,...i,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:l(r)}}n(b,"fetchOptionsFormURLEncoded");function S(r,t="POST"){return{method:t,...i,headers:{"Content-Type":"application/json; charset=utf-8"},body:T(r)}}n(S,"fetchOptionsJson");function u(r,t){return{headers:{Authorization:`Basic ${$(`${r}:${t}`)}`}}}n(u,"fetchOptionsBasicAuth");export{x as A,O as C};